<?php
/**
 * 
 * This class decides what controllers to start depending on the controller value in URL.
 * 
 * @author Jarmo Baltzar
 * @author Vicktor Karlsson
 * 
 * @version 1.0
 */
class MasterController {
	
	/**
	 * Method contains if statements, theese statements decides what controller is being launched depending
	 * on the controller value. 
	 * 
	 * Example of how to initiate FzXmlController and how to call DoControll Method.
	 * <code>
	 * 	<?php
	 *	$masterController = new MasterController();
	 *	$xhtml = $masterController->DoControll();
	 * 	?>
	 * </code>
	 * 
	 * @name DoControll()
	 * @return a object generated by XhtmlBuilder
	 * 
	 */
	function DoControll() {	
		$xhtml = "";
		$style = "";
		$title = "";
		$errors = "";

		//$database = new DatabaseConnection("mydatabase");
		//$database->Connect();
		
		
		// FB settings
		$facebook = new FacebookModel(array(
			  'appId' => '290084561025491',
		 	  'secret' => '69c07ac28481c40604cf24a5c9295682',
			  'fileUpload' => false));
		
		// Drawmenu
		$menuController = new MenuController($facebook);
		$xhtml .= $menuController->DoControll();
		
	
		
		
		            
		if (!isset($_GET["controller"])) {
			// Handles start layout
			$startController = new StartController ();
			$startXhtml = $startController->DoControll ();
			$xhtml .= $startXhtml->GetXhtml ();
			$style .= $startXhtml->GetStyle ();
			$title = $startXhtml->GetTitle ();
			$errors = $startXhtml->GetErrors();
		
		} 

		
		// FzaXmlControll
		if(isset($_GET['controller']) && $_GET['controller'] == "fzxml"){
			
			$fzCntrl = new FzXmlController();
			$fzXhtml = $fzCntrl->DoControll();
			$xhtml .= $fzXhtml->GetXhtml();
			$style .= $fzXhtml->GetStyle ();
			$title = $fzXhtml->GetTitle ();
			$errors = $fzXhtml->GetErrors ();
		}
		
		$xhtmlBuilder = new XhtmlBuilder ($xhtml, $style, $title, $errors);
		return $xhtmlBuilder;
	}
}